//tbClass.modify.vue
<template>
  <el-form
      ref="formref"
      :model="formData"
      label-width="auto"
      :inline="true"
  >

    <el-form-item
        label="id" prop="id"   align="center">
      <div slot="label"><span>id</span></div>
      <el-input  v-model="formData['id']"
                 clearable size="mini" style="width:120px"/>
    </el-form-item>
    <el-form-item
        label="name" prop="name"   align="center">
      <div slot="label"><span>name</span></div>
      <el-input  v-model="formData['name']"
                 clearable size="mini" style="width:120px"/>
    </el-form-item>
    <el-form-item
        label="parent_id" prop="parent_id"   align="center">
      <div slot="label"><span>parent_id</span></div>
      <el-input  v-model="formData['parent_id']"
                 clearable size="mini" style="width:120px"/>
    </el-form-item>


  </el-form>
</template>
<script >
import axios from 'axios';
import { formData, formMethod, PageData, uniqWithKey } from '@/utils/formcommon';
import { openLayer } from '@/utils/layerdialog/layerdialog';
import { alertConfirm,alertWithPayload } from '@base/utils';
import { lodashFillData } from '@/utils/lodashUtil';
import {tbClass} from './tbClass.json.js'
export default{
  data(){
    return {
      total:0,
      formData:{
        ...tbClass,
        ...PageData,
      },
    };
  },
  methods:{
    ...formMethod,
    async initByDialog(_data){
      if(_data?.row?.id){
        var result=await axios.get(`/api/tb_class/getbyid?id=${_data?.row?.id}`,{...this.queryParams}).then(res=>res.data);
        var _data2=result?.data;
        lodashFillData(this.formData,_data2)
        console.log("=>[_data2]", _data2);
      }

      this.formData.typeInfo=_data?.typeInfo;
    },
    async submitByDialog(){
      //validate
      //data operation
      //ajax 提交
      var url='/api/tb_class/add'
      if(this.formData?.id){
        url='/api/tb_class/update'
      }
      var result=await axios.post(url,{...this.formData}).then(res=>res.data)
      alertWithPayload(result)
      return result
    },
  },
};
</script>
